package com.example.myapplication.utils;

import com.example.myapplication.ResourceTable;
import com.example.myapplication.beans.MonitorData;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.window.dialog.CommonDialog;
import ohos.app.Context;

import java.util.Random;

public class MyDialog {
    public static MonitorData monitorData;

    public static void showDialog(Context context){

        CommonDialog commonDialog = new CommonDialog(context);
        commonDialog.setCornerRadius(15);
//        commonDialog.setDuration();
        commonDialog.setSize(736,500);

        DirectionalLayout dl = (DirectionalLayout) LayoutScatter.getInstance(context).parse(ResourceTable.Layout_check_dialog, null, false);

        dl.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                commonDialog.destroy();
            }
        });

        commonDialog.setAutoClosable(true);
        commonDialog.setDuration(5000);
        commonDialog.setContentCustomComponent(dl);
        commonDialog.show();

        Random r1 = new Random();
        Random r2 = new Random();
        Random r3 = new Random();
        int stable = r1.nextInt(101);
        int balance = r2.nextInt(101);
        int coordinated = r3.nextInt(101);

        monitorData = new MonitorData(stable,balance,coordinated);
    }

}
